package com.etong.citymap.util;

import android.content.Context;
import android.util.Log;

import java.lang.Thread.UncaughtExceptionHandler;

public class CityException implements UncaughtExceptionHandler {

	private Context mContext; 

	private UncaughtExceptionHandler defaultExceptionHandler;
	//单例声明CityException; 
	private static CityException customException; 

	private CityException(){        
	} 

	public static CityException getInstance(){ 
		if(customException == null){ 
			customException = new CityException(); 
		} 
		return customException; 
	} 

	@Override 
	public void uncaughtException(Thread thread, Throwable exception) {
		if(defaultExceptionHandler != null){ 

			Log.e("tag", "exception >>>>>>>"+exception.getLocalizedMessage()); 
			//将异常抛出，则应用会弹出异常对话框.这里先注释掉 
			//   defaultExceptionHandler.uncaughtException(thread, exception); 

		} 
	} 

	public void init(Context context) {   
		mContext = context;   
		defaultExceptionHandler  = Thread.getDefaultUncaughtExceptionHandler();   
		Thread.setDefaultUncaughtExceptionHandler(this);  
	}

}
